package com.dmy.vo;

import com.dmy.common.utils.HanyuPinyinUtil;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Setter;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;

import java.io.Serializable;

/**
 * create by huahuadelei for 2020/1/12
 */
@Data
public class FriendListVo implements Serializable {

    private String id;
    private String friendId;
    private String friendName;
    private Integer bindType;
    private String friendUserName;
    private String photo;
    private String userId;

    @Setter(AccessLevel.PRIVATE)
    private String charCase;

    public void setFriendName(String friendName){
        if(friendName!=null && friendName.length()>0){
            try {
               this.charCase = Character.toUpperCase(HanyuPinyinUtil.hanziToPinyin(friendName.toCharArray()[0]).toCharArray()[0])+"";
            } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) {
                badHanyuPinyinOutputFormatCombination.printStackTrace();
            }
        }
        this.friendName = friendName;
    }
}
